package com.cyurs.netty.nio;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @Author: Cyrus
 * @CreateDate: 2020/11/16
 */
public class ChannelDemo3 {
    public static void main(String[] args) throws Exception{
        File file = new File("E:\\a.txt");
        FileInputStream fileInputStream = new FileInputStream(file);
        FileChannel fileInChannel = fileInputStream.getChannel();
        ByteBuffer byteBuffer = ByteBuffer.allocate((int) file.length());
        fileInChannel.read(byteBuffer);

        FileOutputStream fileOutputStream = new FileOutputStream("E:\\b.txt");
        FileChannel fileOuChannel = fileOutputStream.getChannel();
        byteBuffer.flip();
        fileOuChannel.write(byteBuffer);


        fileInChannel.close();
        fileOuChannel.close();
    }
}
